<template>
	<base-page class="base-form" title="干部详情" @back="onCancel()">

	<view class="content">
		<view v-for="(item,index) in activityInfo" :key="index">
				<u-card :title="item.name" padding="30" margin="26rpx" :sub-title="item.createTime" @click="detailsClick(item)">
					<view class="content" slot="body">
						<view style="display: flex;justify-content: space-between;">
							<view class="u-body-item-title u-line-2" style="white-space: break-spaces">
								参与班级：{{ item.className }}
							</view>

						</view>
						<view style="display: flex;justify-content: space-between;">
							<view class="u-body-item-title u-line-2" style="white-space: break-spaces">
								分数：{{ item.score }}
							</view>
						</view>

					</view>
				</u-card>
			</view>
	</view>
	</base-page>
</template>

<script>

	import {
		CourseInfoController
	} from "@/api";
	export default {
		data() {
			return {
				list: [{
					name: '全部通知'
				}, {
					name: '已发布'
				}, {
					name: '草稿',
				}],
				activityInfo: [],
				activityInfoAll: [],
				current: 0,
				swiperCurrent: 0,
				isAnnounce: null, //0 保存 ； 1 保存并发布
				jobDetailsArr: [], //作业详情
			}
		},
		mounted() {
		},
		methods: {
			onCancel() {
				if (this.subPage) {
					this.$emit('close');
				} else {
					uni.navigateBack();
				}
			},
			renderTime(date) {
				var dateee = new Date(date).toJSON();
				return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/,
					'')
			},
			publishActivity(row) {
				let classActivity = {
					id: row.id,
					isAnnounce: 1
				}
				updateInfo(classActivity).then((res) => {
					if (res.code == 200) {
						uni.showToast({
							title: `发布成功`
						})
						this.change(this.current)
					}
				}).catch((err) => {
					console.error(err);
				});
			},

			editActivity(row) {
				uni.navigateTo({
					url: '/pages/sendNotice/index?data=' + encodeURIComponent(JSON.stringify(row))
				})
			},
			delActivity(id) {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '你确定要删除吗',
					success: function(res) {
						if (res.confirm) {
							delteClassActivityInfo(id).then((res) => {
								if (res.code == 200) {
									uni.showToast({
										title: `删除成功`
									})
									that.change(that.current)
								}
							}).catch((err) => {
								console.error(err);
							});
						} else if (res.cancel) {}
					},
				})
			},
			
			change(index) {
				this.current = index;
				switch (index) {
					case 0:
						this.isAnnounce = null
						break;
					case 1:
						this.isAnnounce = 1
						break;
					case 2:
						this.isAnnounce = 0
						break;
				}
				this.activityInfo = [];
				for (var i = 0; i < this.activityInfoAll.length; i++) {

					if (this.isAnnounce == null) {
						this.activityInfo = this.activityInfoAll;
						break;
					}

					if (this.isAnnounce === 1 && this.activityInfoAll[i].isAnnounce === 1) {
						this.activityInfo.push(this.activityInfoAll[i])
						continue;
					}

					if (this.isAnnounce === 0 && this.activityInfoAll[i].isAnnounce === 0) {
						this.activityInfo.push(this.activityInfoAll[i])
					}
				}
			},
		},
		onLoad: function(data) {
			console.log(JSON.parse(decodeURIComponent(data.data)));
			let dataa=JSON.parse(decodeURIComponent(data.data))
			
			// this.classInfo = JSON.parse(decodeURIComponent(data.data))
			// this.valiFormData.name = this.classInfo.className;
			// this.jsData = JSON.parse(decodeURIComponent(data.data))
			let obj={
				officerId:dataa.id
			}
			CourseInfoController.getClassByOfficerId(this,obj)
				.then((res) => {
					this.activityInfo = res
				})
				.catch((e) => {});
		}
	}
</script>

<style scoped>
	page {
		height: 100%;
		background-color: #f2f2f2;
	}

	.is-disabled .uni-easyinput__placeholder-class[data-v-abe12412] {
		color: black !important;
		font-size: 14px !important;
	}

	.uni-easyinput>>>uni-textarea,
	.content>>>#unieasyinputA,
	#unieasyinputA {
		background-color: #ffffff !important;
	}

	#unieasyinputA>>>.uni-easyinput__content-textarea {
		margin: 0 !important;
	}

	#unieasyinputA>>>.is-input-border {
		border: none !important;
	}
</style>
<style scoped lang="scss">
	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32 rpx;
		color: #333;
		padding: 20 rpx 10 rpx;
	}

	.u-body-item image {
		width: 120 rpx;
		flex: 0 0 120 rpx;
		height: 120 rpx;
		border-radius: 8 rpx;
		margin-left: 12 rpx;
	}

	.u-line-2,
	.u-line-3,
	.u-line-4,
	.u-line-5 {
		display: unset !important;
	}
</style>